package com.kinyx.framework.business;

import java.util.Iterator;
import java.util.Map.Entry;

import com.kinyx.framework.Configs;
import com.kinyx.framework.annotation.assist.CanNull;
import com.kinyx.framework.annotation.assist.ReturnNull;

import lombok.AccessLevel;
import lombok.NoArgsConstructor;

/**
 * HTML工具类
 */
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class KHTMLUtils {

	/**
	 * 替换HTML文本中的符号
	 * @param html HTML文本
	 * @return HTML文本
	 */
	@ReturnNull("html == null")
	public static String replaceAllHTMLSymbols(@CanNull String html) {
		if (html == null) { return null; }
		for (final Iterator<Entry<String, String>> iterator = Configs.HTML_SYMBOLS.entrySet().iterator(); iterator.hasNext();) {
			final Entry<String, String> entry = iterator.next();
			html = html.replaceAll(entry.getValue(), entry.getKey());
		}
		return html;
	}

}
